home *** CD-ROM | disk | FTP | other *** search
/ BMUG Revelations / BMUG Revelations.toast / Programming / Programming Languages / Harvest C / MPW Int & Lib / Interfaces / ADSP.h next >
Text File  |  1991-04-17  |  10KB  |  217 lines

  1. /************************************************************
  2.  
  3. Created: Sunday, January 6, 1991 at 8:53 PM
  4.     ADSP.h
  5.     C Interface to the Macintosh Libraries
  6.  
  7.  
  8.         Copyright Apple Computer, Inc.    1986-1990
  9.         All rights reserved
  10.  
  11. ************************************************************/
  12.  
  13.  
  14. #ifndef __ADSP__
  15. #define __ADSP__
  16.  
  17. #ifndef __APPLETALK__
  18. #include <AppleTalk.h>
  19. #endif
  20.  
  21.  
  22.  
  23.  
  24.  
  25. /* driver control ioResults */
  26.  
  27. #define errRefNum -1280                         /* bad connection refNum */
  28. #define errAborted -1279                        /* control call was aborted */
  29. #define errState -1278                          /* bad connection state for this operation */
  30. #define errOpening -1277                        /* open connection request failed */
  31. #define errAttention -1276                      /* attention message too long */
  32. #define errFwdReset -1275                       /* read terminated by forward reset */
  33. #define errDSPQueueSize -1274                   /* DSP Read/Write Queue Too small */
  34. #define errOpenDenied -1273                     /* open connection request was denied */
  35.  
  36. /*driver control csCodes*/
  37. #define dspInit 255                             /* create a new connection end */
  38. #define dspRemove 254                           /* remove a connection end */
  39. #define dspOpen 253                             /* open a connection */
  40. #define dspClose 252                            /* close a connection */
  41. #define dspCLInit 251                           /* create a connection listener */
  42. #define dspCLRemove 250                         /* remove a connection listener */
  43. #define dspCLListen 249                         /* post a listener request */
  44. #define dspCLDeny 248                           /* deny an open connection request */
  45. #define dspStatus 247                           /* get status of connection end */
  46. #define dspRead 246                             /* read data from the connection */
  47. #define dspWrite 245                            /* write data on the connection */
  48. #define dspAttention 244                        /* send an attention message */
  49. #define dspOptions 243                          /* set connection end options */
  50. #define dspReset 242                            /* forward reset the connection */
  51. #define dspNewCID 241                           /* generate a cid for a connection end */
  52.  
  53. /* connection opening modes */
  54. #define ocRequest 1                             /* request a connection with remote */
  55. #define ocPassive 2                             /* wait for a connection request from remote */
  56. #define ocAccept 3                              /* accept request as delivered by listener */
  57. #define ocEstablish 4                           /* consider connection to be open */
  58.  
  59. /* connection end states */
  60. #define sListening 1                            /* for connection listeners */
  61. #define sPassive 2                              /* waiting for a connection request from remote */
  62. #define sOpening 3                              /* requesting a connection with remote */
  63. #define sOpen 4                                 /* connection is open */
  64. #define sClosing 5                              /* connection is being torn down */
  65. #define sClosed 6                               /* connection end state is closed */
  66.  
  67. /* client event flags */
  68. #define eClosed 0x80                            /* received connection closed advice */
  69. #define eTearDown 0x40                          /* connection closed due to broken connection */
  70. #define eAttention 0x20                         /* received attention message */
  71. #define eFwdReset 0x10                          /* received forward reset advice */
  72.  
  73. /* miscellaneous constants */
  74. #define attnBufSize 570                         /* size of client attention buffer */
  75. #define minDSPQueueSize 100                     /* Minimum size of receive or send Queue */
  76.  
  77. /* connection control block */
  78. struct TRCCB {
  79.     unsigned char *ccbLink;                     /* link to next ccb */
  80.     unsigned short refNum;                      /* user reference number */
  81.     unsigned short state;                       /* state of the connection end */
  82.     unsigned char userFlags;                    /* flags for unsolicited connection events */
  83.     unsigned char localSocket;                  /* socket number of this connection end */
  84.     AddrBlock remoteAddress;                    /* internet address of remote end */
  85.     unsigned short attnCode;                    /* attention code received */
  86.     unsigned short attnSize;                    /* size of received attention data */
  87.     unsigned char *attnPtr;                     /* ptr to received attention data */
  88.     unsigned char reserved[220];                /* for adsp internal use */
  89. };
  90.  
  91. typedef struct TRCCB TRCCB;
  92. typedef TRCCB *TPCCB;
  93.  
  94. /* init connection end parameters */
  95. struct TRinitParams {
  96.     TPCCB ccbPtr;                               /* pointer to connection control block */
  97.     ProcPtr userRoutine;                        /* client routine to call on event */
  98.     unsigned short sendQSize;                   /* size of send queue (0..64K bytes) */
  99.     unsigned char *sendQueue;                   /* client passed send queue buffer */
  100.     unsigned short recvQSize;                   /* size of receive queue (0..64K bytes) */
  101.     unsigned char *recvQueue;                   /* client passed receive queue buffer */
  102.     unsigned char *attnPtr;                     /* client passed receive attention buffer */
  103.     unsigned char localSocket;                  /* local socket number */
  104. };
  105.  
  106. typedef struct TRinitParams TRinitParams;
  107.  
  108. /* open connection parameters */
  109. struct TRopenParams {
  110.     unsigned short localCID;                    /* local connection id */
  111.     unsigned short remoteCID;                   /* remote connection id */
  112.     AddrBlock remoteAddress;                    /* address of remote end */
  113.     AddrBlock filterAddress;                    /* address filter */
  114.     unsigned long sendSeq;                      /* local send sequence number */
  115.     unsigned short sendWindow;                  /* send window size */
  116.     unsigned long recvSeq;                      /* receive sequence number */
  117.     unsigned long attnSendSeq;                  /* attention send sequence number */
  118.     unsigned long attnRecvSeq;                  /* attention receive sequence number */
  119.     unsigned char ocMode;                       /* open connection mode */
  120.     unsigned char ocInterval;                   /* open connection request retry interval */
  121.     unsigned char ocMaximum;                    /* open connection request retry maximum */
  122. };
  123.  
  124. typedef struct TRopenParams TRopenParams;
  125.  
  126. /* close connection parameters */
  127. struct TRcloseParams {
  128.     unsigned char abort;                        /* abort connection immediately if non-zero */
  129. };
  130.  
  131. typedef struct TRcloseParams TRcloseParams;
  132.  
  133. /* client status parameter block */
  134. struct TRstatusParams {
  135.     TPCCB ccbPtr;                               /* pointer to ccb */
  136.     unsigned short sendQPending;                /* pending bytes in send queue */
  137.     unsigned short sendQFree;                   /* available buffer space in send queue */
  138.     unsigned short recvQPending;                /* pending bytes in receive queue */
  139.     unsigned short recvQFree;                   /* available buffer space in receive queue */
  140. };
  141.  
  142. typedef struct TRstatusParams TRstatusParams;
  143.  
  144. /* read/write parameter block */
  145. struct TRioParams {
  146.     unsigned short reqCount;                    /* requested number of bytes */
  147.     unsigned short actCount;                    /* actual number of bytes */
  148.     unsigned char *dataPtr;                     /* pointer to data buffer */
  149.     unsigned char eom;                          /* indicates logical end of message */
  150.     unsigned char flush;                        /* send data now */
  151. };
  152.  
  153. typedef struct TRioParams TRioParams;
  154.  
  155. /* attention parameter block */
  156. struct TRattnParams {
  157.     unsigned short attnCode;                    /* client attention code */
  158.     unsigned short attnSize;                    /* size of attention data */
  159.     unsigned char *attnData;                    /* pointer to attention data */
  160.     unsigned char attnInterval;                 /* retransmit timer in 10-tick intervals */
  161. };
  162.  
  163. typedef struct TRattnParams TRattnParams;
  164.  
  165. /* client send option parameter block */
  166. struct TRoptionParams {
  167.     unsigned short sendBlocking;                /* quantum for data packets */
  168.     unsigned char sendTimer;                    /* send timer in 10-tick intervals */
  169.     unsigned char rtmtTimer;                    /* retransmit timer in 10-tick intervals */
  170.     unsigned char badSeqMax;                    /* threshold for sending retransmit advice */
  171.     unsigned char useCheckSum;                  /* use ddp packet checksum */
  172. };
  173.  
  174. typedef struct TRoptionParams TRoptionParams;
  175.  
  176. /* new cid parameters */
  177. struct TRnewcidParams {
  178.     unsigned short newcid;                      /* new connection id returned */
  179. };
  180.  
  181. typedef struct TRnewcidParams TRnewcidParams;
  182.  
  183. /* ADSP CntrlParam ioQElement */
  184. struct DSPParamBlock
  185.     {
  186.     struct            QElem *qLink;
  187.     short            qType;
  188.     short            ioTrap;
  189.     Ptr             ioCmdAddr;
  190.     ProcPtr         ioCompletion;
  191.     OSErr            ioResult;
  192.     char            *ioNamePtr;
  193.     short            ioVRefNum;
  194.     short            ioCRefNum;                 /* adsp driver refNum */
  195.     short            csCode;                    /* adsp driver control code */
  196.     long            qStatus;                    /* adsp internal use */
  197.     short            ccbRefNum;                 /* connection end refNum */
  198.     union
  199.         {
  200.             TRinitParams    initParams;         /* dspInit, dspCLInit */
  201.             TRopenParams    openParams;         /* dspOpen, dspCLListen, dspCLDeny */
  202.             TRcloseParams    closeParams;       /* dspClose, dspRemove */
  203.             TRioParams        ioParams;         /* dspRead, dspWrite */
  204.             TRattnParams    attnParams;         /* dspAttention */
  205.             TRstatusParams    statusParams;     /* dspStatus */
  206.             TRoptionParams    optionParams;     /* dspOptions */
  207.             TRnewcidParams    newCIDParams;     /* dspNewCID */
  208.             } u;
  209.     };
  210.  
  211. typedef struct DSPParamBlock DSPParamBlock;
  212. typedef struct DSPParamBlock *DSPPBPtr;
  213.  
  214.  
  215.  
  216. #endif
  217.